﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _2_show : System.Web.UI.Page
{
    public string d;
    protected void Page_Load(object sender, EventArgs e)
    {
        int a = int.Parse(Request.QueryString["hm"]);
        if (!IsPostBack)
        {
            if (a == 1)
            {
                d = "申报材料";
                Label2.Text = "";
            }
            else if (a == 2)
            {
                d = "教学队伍";
                Label2.Text = "";
            }
            else if (a == 3)
            {
                d = "课程评价";
                Label2.Text = "";
            }
            else if (a == 4)
            {
                d = "体育科研";
                Label2.Text = "";
            }
            else if (a == 5)
            {
                d = "政策措施";
                Label2.Text = "";
            }
            else if (a == 6)
            {
                d = "课堂互动";
                Label2.Text = "";

            }
            else if (a == 7)
            {
                d = "网站公告";
                Label2.Text = "PUBLIC NOTICE";
            
            }
            else if (a == 8)
            {
                d = "学习资源";
                Label2.Text = "STUDY RESOURCE";           
            }
            else if (a == 9)
            {
                d = "实践教学";
                Label2.Text = "PRACTICE AND TEACHING";
            }
            else if (a == 10)
            {
                d = "课程录像";
                Label2.Text = "CURRICLUM VEDIO";
            }


            rpTest.DataSource = pds();
            rpTest.DataBind();
        }
    }
    protected PagedDataSource pds()
    {
        OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0 ;Data Source=|DataDirectory|\\web.mdb");
        con.Open();
        OleDbCommand cmd = new OleDbCommand("select * from news where shenhe='已审核'and lanmu='" + d + "' order by id desc", con);
        OleDbDataAdapter sda = new OleDbDataAdapter();
        sda.SelectCommand = cmd;
        DataSet ds = new DataSet();
        sda.Fill(ds, "news");
        Label1.Text = d;
        PagedDataSource pds = new PagedDataSource();
        pds.DataSource = ds.Tables["news"].DefaultView;//必须设为DefaultView,不能设置成Table
        pds.AllowPaging = true;
        pds.PageSize = 4;
        pds.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]);
        con.Close();
        return pds;
    }
    protected void rpTest_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Footer)//页脚绑定时
        {

            HyperLink hlPrevious = (HyperLink)e.Item.FindControl("hlPrevious");
            HyperLink hlNext = (HyperLink)e.Item.FindControl("hlNext");
            DropDownList ddlJumpPage = (DropDownList)e.Item.FindControl("ddlJumpPage");
            int pagecount = pds().PageCount;
            int currentpage = pds().CurrentPageIndex;
            if (currentpage <= 0)
            {
                hlPrevious.Enabled = false;
                hlNext.Enabled = true;
                hlPrevious.Visible = false;
            }
            else
            {

                hlPrevious.NavigateUrl = "2_show.aspx?hm=" + Request.QueryString["hm"] + "&&page=" + (currentpage - 1);
            }
            if (currentpage >= pagecount - 1)
            {
                hlPrevious.Enabled = true;
                hlNext.Enabled = false;
                hlNext.Visible = false;
            }
            else
            {
                hlNext.NavigateUrl = "2_show.aspx?hm=" + Request.QueryString["hm"] + "&&page=" + (currentpage + 1);
            }

        }

    }
}
